cmake_minimum_required(VERSION 3.14)

set(PROJECT_TARGET AnycubicPhotonWorkshop)
project(${PROJECT_TARGET})

#SDK
if(WIN32)
    SET(WorkshopSDK_PATH D:/WorkshopSDK)
else(WIN32)
    SET(WorkshopSDK_PATH ../../../WorkshopSDK)
endif(WIN32)

set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

## 个别moc
set(moc_files
    ../common/include/svg_image.h
    ../common/include/enum_file.h
    ../common/include/base_file.h
)

## 链接Qt相关的库
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS core quick gui widgets svg xml)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Quick gui widgets svg xml)	

## 代码中的宏定义
set(VERSION 3.3.0.0)
add_compile_definitions(APP_VERSION="${VERSION}")
				
## 依赖第三方库	
#ctk
set(ctk_include ../3rdparty/ctk/include/ctk-0.1)
set(ctk_lib ../3rdparty/ctk/release/ctk-0.1)
set(ctk_dll_names CTKCore CTKPluginFramework CTKWidgets)

#common
file(GLOB_RECURSE COMMON_SRC "../common/cpp/*.cpp" "../common/cpp/*.c")
file(GLOB_RECURSE COMMON_INC "../common/cpp/*.hpp" "../common/cpp/*.h")
set(common_include ../common/include)
set(qserializer_include ../3rdparty/QSerializer/src/qserializer.h)

#log4qt
file(GLOB_RECURSE LOG_SRC "../3rdparty/log4qt/install/log/*.cpp" "../3rdparty/log4qt/install/log/*.c")
set(log_include ../3rdparty/log4qt/install/include 
				../3rdparty/log4qt/install/log)
set(log_lib ../3rdparty/log4qt/install/lib)
set(log_dll_names log4qt)

#vox
if(WIN32)
    set(vox_include ${WorkshopSDK_PATH}/2022/vdsdk_install/win/x86_64/include)
    set(vox_lib ${WorkshopSDK_PATH}/2022/vdsdk_install/win/x86_64/lib)
    set(vox_dll_names VoxMeshData VoxSDKTriangleLayout2D VoxSDKTriangleHollow
        VoxSDKTriangleEdit VoxSDKTriangleFix VoxGeoKernelSystem VoxSDKAuthentication VoxSDKSupportGeneration)
else(WIN32)

endif(WIN32)


## 本工程
#main
file(GLOB_RECURSE MAIN_SRC "*.cpp" "*.c")
file(GLOB_RECURSE MAIN_INC "*.hpp" "*.h")
file(GLOB_RECURSE MAIN_QRC "*.MF")

qt5_add_big_resources(MAIN_SRC  "main.qrc")

include_directories(${vox_include} ${common_include} ${ctk_include} ${qserializer_include} ${log_include})
link_directories(${vox_lib} ${ctk_lib} ${log_lib})
add_executable(${PROJECT_TARGET} ${moc_files} ${COMMON_SRC} ${LOG_SRC} ${MAIN_SRC} ${MAIN_QRC})

target_link_libraries(${PROJECT_TARGET}
    Qt${QT_VERSION_MAJOR}::Core
    Qt${QT_VERSION_MAJOR}::Quick
    Qt${QT_VERSION_MAJOR}::Gui
    Qt${QT_VERSION_MAJOR}::Svg
	Qt${QT_VERSION_MAJOR}::Xml
    Qt${QT_VERSION_MAJOR}::Widgets
	${ctk_dll_names}
	${log_dll_names}
    ${vox_dll_names}
  )


set_target_properties(${PROJECT_TARGET} PROPERTIES AUTOMOC TRUE)
install(TARGETS ${PROJECT_TARGET} LIBRARY DESTINATION ./../package/win/win_release/plugins)


